package com.team11.server.controller.student;


import com.team11.server.pojo.student.StudentInformation;
import com.team11.server.service.impl.SInformationServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dk
 * @since 2021-06-19
 */
@RestController
@CrossOrigin
@RequestMapping("/student")
@Api(tags = "学生接口")
public class StudentSInformationController {
    @Resource
    private SInformationServiceImpl sInformationService;

    @GetMapping ("/detail/{sNumber}")
    @ApiOperation(value = "通过学生学号查询学生信息")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "学生学号",name = "sNumber",dataType = "String")
    })
    public StudentInformation getStuDetail(@PathVariable String sNumber){
        return sInformationService.getDetails(sNumber);
    }
    @PutMapping("/updateEmail/{sNumber}")
    @ApiOperation(value = "更新邮箱地址")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "学生学号",name = "sNumber"),
            @ApiImplicitParam(value = "邮箱地址",name = "sEmail")
    })
    public String updateStuEmail(@PathVariable String sNumber,String sEmail){
        return sInformationService.updateEmail(sNumber,sEmail);
    }
    @PutMapping("/updatePhone/{sNumber}")
    @ApiOperation(value = "更新手机号码")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "学生学号",name = "sNumber"),
            @ApiImplicitParam(value = "手机号码",name = "sPhone")
    })
    public String updateStuPhone(@PathVariable String sNumber,String sPhone){
        return sInformationService.updatePhone(sNumber,sPhone);
    }

}
